FROM php:7.3-fpm-alpine

ARG PHP_EXTENSIONS

RUN sed -i "s/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g" /etc/apk/repositories
RUN apk --no-cache add tzdata && cp "/usr/share/zoneinfo/Asia/Shanghai" /etc/localtime && echo "Asia/Shanghai" > /etc/timezone

COPY ./extensions /tmp/extensions
WORKDIR /tmp/extensions

ENV EXTENSIONS=",${PHP_EXTENSIONS},"
ENV MC="-j$(nproc)"

RUN export MC="-j$(nproc)" && chmod +x install.sh && sh install.sh && rm -rf /tmp/extensions

RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
	&& php composer-setup.php \
	&& php -r "unlink('composer-setup.php');" \
	&& mv composer.phar /usr/local/bin/composer \
	&& composer self-update \
	&& composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php

WORKDIR /wwwroot